<script type="text/javascript">
    jQuery(document).ready(function() {
    var sheepItForm = jQuery('#sheepItForm').sheepIt({
        separator: '',
        allowRemoveLast: true,
        allowRemoveCurrent: true,
        allowRemoveAll: true,
        allowAdd: true,
        allowAddN: true,
        maxFormsCount: 20,
        minFormsCount: 0,
        iniFormsCount: 1
    });
});
</script>
<script type="text/javascript">
           jQuery(document).ready(function(){
               // binds form submission and fields to the validation engine
               jQuery("#HojasrutaNuevotrabajoForm").validationEngine();
               jQuery( "#datepicker" ).datepicker();
           });
 </script>
<!-- Columns -->
<div id="cols" class="box"> 

    <!-- Aside (Left Column) -->
    <div id="aside" class="box">
        <div class="padding box"> 

            <!-- Logo (Max. width = 200px) -->
            <p id="logo"><a href="#"><?php echo $this->Html->image('logo.gif',
array('alt' => 'logo')) ?></a></p>

            <!-- Search -->
            <form action="#" method="get" id="search">
                <fieldset>
                    <legend>Search</legend>
                    <p>
                        <input type="text" size="17" name="" class="input-text" />
                        &nbsp;
                        <input type="submit" value="OK" class="input-submit-02" />
                        <br />
                        <a href="javascript:toggle('search-options');" class="ico-drop">Advanced search</a></p>

                    <!-- Advanced search -->
                    <div id="search-options" style="display:none;">
                        <p>
                            <label>
                                <input type="checkbox" name="" checked="checked" />
                                Option I.</label>
                            <br />
                            <label>
                                <input type="checkbox" name="" />
                                Option II.</label>
                            <br />
                            <label>
                                <input type="checkbox" name="" />
                                Option III.</label>
                        </p>
                    </div>
                    <!-- /search-options -->

                </fieldset>
            </form>

            <!-- Create a new project -->
            <p id="btn-create" class="box"><a href="#"><span>Create a new project</span></a></p>
        </div>
        <!-- /padding -->

        <ul class="box">
            <li><a href="#">Lorem ipsum</a></li>
            <li><a href="#">Lorem ipsum</a></li>
            <li><a href="#">Lorem ipsum</a></li>
            <li id="submenu-active"><a href="#">Active Page</a> <!-- Active -->
                <ul>
                    <li><a href="#">Lorem ipsum</a></li>
                    <li><a href="#">Lorem ipsum</a></li>
                    <li><a href="#">Lorem ipsum</a></li>
                    <li><a href="#">Lorem ipsum</a></li>
                    <li><a href="#">Lorem ipsum</a></li>
                </ul>
            </li>
            <li><a href="#">Lorem ipsum</a></li>
            <li><a href="#">Lorem ipsum</a>
                <ul>
                    <li><a href="#">Lorem ipsum</a></li>
                    <li><a href="#">Lorem ipsum</a></li>
                    <li><a href="#">Lorem ipsum</a></li>
                </ul>
            </li>
            <li><a href="#">Lorem ipsum</a></li>
        </ul>
    </div>
    <!-- /aside -->

    <hr class="noscreen" />

    <!-- Content (Right Column) -->
    <div id="content" class="box">
        <h1>Trabajo # <?php echo $id; ?> </h1>
       <!-- Form -->
          
   <fieldset>
        <legend>Insertar datos del trabajo</legend>
        <?php echo $this->Form->create('Ordenespedido'); ?>
        
        <table class="nostyle">
        <?php echo $this->Form->hidden('trabajo_id', array('value' => $id));
//echo $this->Form->hidden('usuario_id', array('value'=>$usuario));


?>
          <tr VALIGN=MIDDLE>
              <td style="width:120px;">Descripci&oacute;n:</td>
              <td>
              <?php echo $this->Form->textarea('descripcion', array(
              'id' => 'nomb',
              'rows' => '2',
              'cols' => '100')); 
              ?>
              </td>
          </tr>
          <tr>
             <td>Encargado:</td>
             <td>
             <?php if (!empty($empleados)): ?>
             <?php echo $this->Form->input('encargado_id', array(
                    'type' => 'select',
                    'options' => $empleados,
                    'selected' => $datos['Hojasruta']['encargado_id'])); ?>
             <?php //echo $this->Form->select('encargado_id', $empleados); ?>
             <?php else: ?>
             No existen empleados
             <?php endif; ?>
             </td>
          </tr>
          <tr>
             <td>Sucursal:</td>
             <td>
             <?php if (!empty($sucursales)): ?>
             <?php echo $this->Form->input('sucursal_id', array(
                    'type' => 'select',
                    'options' => $sucursales,
                    'selected' => $datos['Hojasruta']['sucursal_id'])); ?>
             <?php //echo $this->Form->select('sucursal_id', $sucursales); ?>
             <?php else: ?>
             No existen sucursales registradas
             <?php endif; ?>
             </td>
          </tr>
          <!--parte del formulario de asignaciones empleados-->
          <tr>
              <td>Empleados</td>  
              <td>
              <table class="mitable">
              <tr>
              <td>
              <!-- sheepIt Form -->
              
                <div id="sheepItForm">
                 
                  <!-- Form template-->
                  <?php if(!empty($empmaquinas)):?>
                  <?php foreach($empmaquinas as $dato):?>
                  <div id="sheepItForm_template">
                    <label for="sheepItForm_#index#_phone">Empleado <span id="sheepItForm_label"></span></label>
                    <!--<input id="sheepItForm_#index#_phone" name="person[phones][#index#][phone]" type="text"/>-->
                    <?php /*echo $this->Form->select(null, $empleados,array('selected' => $dato['Empleadostrabajo']['empleado_id']), 
                                                                    array('name'=>"data[Empleadostrabajo][#index#][empleado_id]")
                                                   );*/?>
                    <?php //debug($dato);
                    //debug($dato['Empleadostrabajo']['empleado_id']);
                    ?>
                    <?php echo $this->Form->input(null, array(
                    'name'=>"data[Empleadosordene][#index#][empleado_id]",
                    'type' => 'select',
                    'options' => $empleados,
                    'selected' => $dato['Empleadostrabajo']['empleado_id'])); ?>
                    <label for="sheepItForm_#index#_machine">Maquina <span id="sheepItForm_label"></span></label>
                    <?php //echo $this->Form->select(null, $maquinas, array('name'=>"data[Empleadostrabajo][#index#][maquinaria_id]"));?>
                    <?php echo $this->Form->input(null, array('name'=>"data[Empleadosordene][#index#][maquinaria_id]", 'type' => 'select', 'options' => $maquinas, 'selected' => $dato['Empleadostrabajo']['maquinaria_id']));?>
                    <?php 
                    //echo $this->Html->image("buttons/cross.png", array('id'=>"SheepItForm_remove_current"));
                    ?>
                    <a id="sheepItForm_remove_current">
                      <img class="delete" src="../../img/buttons/cross.png" width="16" height="16" border="0">
                    </a>
                  </div>
                  <?php endforeach;?>
                  <?php else:?>
                  <div id="sheepItForm_template">
                    <label for="sheepItForm_#index#_phone">Empleado <span id="sheepItForm_label"></span></label>
                    <!--<input id="sheepItForm_#index#_phone" name="person[phones][#index#][phone]" type="text"/>-->
                    <?php echo $this->Form->select(null, $empleados, array('name'=>"data[Empleadostrabajo][#index#][empleado_id]"));?>
                    <label for="sheepItForm_#index#_machine">Maquina <span id="sheepItForm_label"></span></label>
                    <?php echo $this->Form->select(null, $maquinas, array('name'=>"data[Empleadostrabajo][#index#][maquinaria_id]"));?>
                    <?php 
                    //echo $this->Html->image("buttons/cross.png", array('id'=>"SheepItForm_remove_current"));
                    ?>
                    <a id="sheepItForm_remove_current">
                      <img class="delete" src="../../img/buttons/cross.png" width="16" height="16" border="0">
                    </a>
                  </div>
                  <?php endif;?>
                  <!-- /Form template-->
                   
                  <!-- No forms template -->
                  <div id="sheepItForm_noforms_template">Sin empleados</div>
                  <!-- /No forms template-->
                   
                  <!-- Controls -->
                  <div id="sheepItForm_controls">
                    <div id="sheepItForm_add" class="btn form add"><a><span>A&ntilde;adir</span></a></div>
                    <div id="sheepItForm_remove_last" class="btn form remove"><a><span>Remover</span></a></div>
                    <div id="sheepItForm_remove_all" class="btn form removeAll"><a><span>Remove todos</span></a></div>
                    <div id="sheepItForm_add_n">
                      <input id="sheepItForm_add_n_input" type="text" size="4" style="float: left;"/>
                      <div id="sheepItForm_add_n_button" class="btn form add"><a><span>A&ntilde;adir varios</span></a></div></div>
                  </div>
              
                  <!-- /Controls -->
                   
                </div>
                
                <!-- /sheepIt Form -->
                </td>
                </tr>
              </table>
                   
              </td>
            
          </tr>
          <!--fin formulario de asignaciones de empleados-->
          <tr>
             <td>Costo final:</td>
             <td><?php echo $this->Form->text('costofinal', array('value'=>$datos['Hojasruta']['costoinicial']));?></td>
             <?php echo $this->Form->hidden('fecha', array('value'=>date('Y-m-d H:m:s')));?>
          </tr>
          <tr>
             <td>
             <?php echo $this->Form->input('estado_id', array(
                    'type' => 'select',
                    'options' => $opt,
                    'selected' => '1')); ?>
             </td>
          </tr>
          <tr>
             <td class="t-right">
             <?php $option = array('Value' => 'guardar', 'class' =>
            "input-submit"); ?>
             <?php echo $this->Form->end($option); ?>
            </td>
          </tr>
       </table>
     
    </fieldset>
      
          
    <!-- /fin form --> 
        <div class="grid-buttons">
                     <!--<div class="title-grid"><span>Acciones</span></div>-->
            <div class="content-gird">
                    <div style="float: left;">
                        <input type="button" class="button" value="Atras" onclick="javascript:history.back();" /> 
                    </div>
                <div class="clear"> </div>
            </div>

        </div>

    </div>
    <!-- /content --> 

</div>
<!-- /cols -->
